package cn.wit.testalgorithms;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.Stack;

import org.junit.Test;

public class Test1 {
	public static void main(String[] args) {

	}
	 @Test
	 public void Test1() {
	 int[] a= {1,2,3,4,5};
	// Arrays.sort(a);
	// System.out.println(a[a.length-1]);
		 Map<Integer,Integer> map = new HashMap<>();
		 for(int i = 0;i<a.length;i++) {
		 map.put(a[i], i);
		 }
		 Arrays.sort(a);
		 System.out.println(map.get(a[a.length-1]));
	 }

	@Test
	public void Test2() {
		String start = "RXXLRXRXL";
		System.out.println(start.charAt(0) + " " + start.charAt(1));
		char temp;
		StringBuilder sb = new StringBuilder(start);
		sb.setCharAt(0, 'L');
		sb.setCharAt(1, 'R');
		System.out.println(sb.charAt(0) + " " + sb.charAt(1));
	}

	@Test
	public void Test3() {
		int max = 0;
		for (int i = 1; i <= 100; i++) {
			if (i % 13 == 0 && i > max) {
				max = i;
			}
		}
		System.out.println(max);
	}
	@Test
	public void Test4() {
		int[] a= {1,2,4};
		System.out.println(Arrays.toString(a));
	}
	@Test
	public void Test5() {
		StringBuilder r=new StringBuilder("sjhsj");
		System.out.println(r.charAt(1));
	}
	
	
	//测试一下set集合
	@Test
	public void Test6() {
		int[] a = { 2, 2, 1 };
		
		//转换成字符串
		String s = String.valueOf(a);
		StringBuilder sb = new StringBuilder(s);
//		System.out.println(a.length);
		
		Set<String> set = new HashSet<String>();
		
		for(int i =0;i<a.length;i++) {
			if(set.contains(i)) {
				System.out.println("重复："+sb.charAt(i));
			}
//			System.out.println(map.containsKey(i));
//			System.out.println(i);
//			map.put(i, s.charAt(i));
//			set.add();
//			set.add();
		}
	
		
	}
	
	@Test
	public void test() {
		Stack<Character> sk = new Stack<Character>();
		
		sk.push('1');
		
		if(sk.peek() != '1') {
		
			System.out.println("没有进入");
		
		}
		System.out.println(sk.pop());
		
	}


}
